import { defineStore } from "pinia";
import {ref} from 'vue'

export const useSettingStore = defineStore('setting',()=>{

  const isCollapse = ref(false);
  const tags = ref([
    {
      name: 'Home',
      path: '/home',
      meta:{
        title: '首页'
      },
      icon: 'home',
    }
  ])
  const currentMenu = ref()
  const selectMenu = val =>{
    const index = tags.value.findIndex(item=>item.name === val.name)
    if(index === -1){
      tags.value.push(val)
    }
    currentMenu.value = val

  }
  //头部tag关闭
  const closeMenu = val =>{
    const index = tags.value.findIndex(item=>item.name === val.name)
    tags.value.splice(index,1);
  }
  return {
    isCollapse,
    tags,
    currentMenu,
    selectMenu,
    closeMenu,
  }
})
